﻿// For an introduction to the Page Control template, see the following documentation:
// http://go.microsoft.com/fwlink/?LinkId=232511
(function () {
    "use strict";

    WinJS.UI.Pages.define("/pages/imagezoom/imagezoom.html", {
        // This function is called whenever a user navigates to this page. It
        // populates the page elements with the app's data.

        itemGalleryInvoked: function (args) {
            var item = args.detail.itemIndex;
            var imageList = document.getElementById('basicFlipView').winControl;
            imageList.currentPage = item;
        },

        ready: function (element, options) {
            // TODO: Initialize the page here.
            
            var ssDataSource = options.ScreenshotsData;

            for (var i = 0; i < ssDataSource.length; i++) {
                ssDataSource[i].Path = "http://www.baixaki.com.br/imagens/" + ssDataSource[i].Path + ".jpg";
            }

            var BindingShots = new WinJS.Binding.List(ssDataSource);

            element.querySelector('.pagetitle').textContent = options.ApplicationName;

            var imageList = element.querySelector('#basicFlipView').winControl;
            imageList.itemDataSource = BindingShots.dataSource;

            var imageGallery = element.querySelector('#imageGallery').winControl;
            imageGallery.itemDataSource = BindingShots.dataSource;

            imageGallery.oniteminvoked = this.itemGalleryInvoked.bind(this);
            imageList.currentPage = options.ItemDetail.itemIndex;

        },

        unload: function () {
            // TODO: Respond to navigations away from this page.
        },

        updateLayout: function (element, viewState, lastViewState) {
            /// <param name="element" domElement="true" />

            // TODO: Respond to changes in viewState.
        }
    });
})();
